/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Server.domain;

/**
 *
 * @author user
 */
public class Player
{
	//name
	private String name = "";
	private String ip = "";
	
	//location
	private float x_pos = 100;
	private float y_pos = 100;
	private int speed = 50;
	
	//time out counter
	int timeOut = 0,kickTime = 1000;
	boolean kick = false;
	
	//keys
	private boolean left=false,right=false,up=false,down=false;
	
	public Player(String n)
	{
		name = n;
		System.out.println(name+" Connected");
	}
	public void advance(float eT)
	{
		stepTimeout(eT);
		move(eT);
	}
	public void stepTimeout(float eT)
	{
		timeOut += eT;
		if(timeOut>kickTime)
			kick = true;
	}
	public void move(float eT)
	{
		if(left && right)
		{
		}
		else if(left)
		{
			x_pos -= speed * (eT/1000);
		}
		else if(right)
		{
			x_pos += speed * (eT/1000);
		}
		
		if(up && down)
		{
		}
		else if(up)
		{
			y_pos -= speed * (eT/1000);
		}
		else if(down)
		{
			y_pos += speed * (eT/1000);
		}
	}
	public void resetKeys()
	{
		timeOut=0;
		left=false;
		right=false;
		up=false;
		down=false;
	}
	
	public boolean getKick()
	{
		return kick;
	}
	public String getName()
	{
		return name;
	}
	public String getIP()
	{
		return ip;
	}
	public float getX()
	{
		return x_pos;
	}
	public float getY()
	{
		return y_pos;
	}
	
	public void setName(String n)
	{
		name = n;
	}
	public void setIP(String i)
	{
		ip = i;
	}
	public void setX(float x)
	{
		x_pos  = x;
	}
	public void setY(float y)
	{
		y_pos = y;
	}
	public void setLeft(boolean l)
	{
		left = l;
	}
	public void setRight(boolean r)
	{
		right = r;
	}
	public void setUp(boolean u)
	{
		up = u;
	}
	public void setDown(boolean d)
	{
		down = d;
	}
}
